﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BabyFood.Entities;
using BabyFood.Data;

public partial class Suc_Khoe_Cua_Con_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HienThiBenh();
            HienThiBenhall();
            HienThiSongSinh();
            HienThiSongSinhall();
            InitLinkChude();
        }
        Session["Title"] = "Sức Khỏe Của Con";
    }

    private void HienThiBenh()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=10 and Tinnong=1", "NgayCapNhat DESC", 0, 1, out TotalRows);

        dlbenh.DataSource = TList_TinTuc;
        dlbenh.DataBind();
    }

    private void HienThiBenhall()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=10 and Tinnong=1", "NgayCapNhat DESC", 0, 3, out TotalRows);

        dlbenhall.DataSource = TList_TinTuc;
        dlbenhall.DataBind();
    }

    private void HienThiSongSinh()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=11 and Tinnong=1", "NgayCapNhat DESC", 0, 1, out TotalRows);

        dlsongsinh.DataSource = TList_TinTuc;
        dlsongsinh.DataBind();
    }

    private void HienThiSongSinhall()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=11 and Tinnong=1", "NgayCapNhat DESC", 0, 3, out TotalRows);

        dlsongsinhall.DataSource = TList_TinTuc;
        dlsongsinhall.DataBind();
    }

    /// <summary>
    /// Handles ItemDataBound, Binds ExchangesTo to the Child DataList
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dlFromTrades_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {

            DataListItem parentList = e.Item;
            HiddenField lit_Name = (HiddenField)parentList.FindControl("H_CatalogId");
            string i = (lit_Name.Value).ToString();
            int j = Convert.ToInt32(i);            
        }
    }

    public string GetLienKet()
    {
        return Common.sPathUpLienKet;
    }


    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
    public void InitLinkChude()
    {
        // Bệnh
        HyperLink32.NavigateUrl = "~/chude/" + "10" + "_" + GetTieuDe("Bệnh") + ".aspx";
        HyperLink1.NavigateUrl = "~/chude/" + "10" + "_" + GetTieuDe("Bệnh") + ".aspx";

        HyperLink3.NavigateUrl = "~/chude/" + "11" + "_" + GetTieuDe("Song sinh") + ".aspx";
        HyperLink2.NavigateUrl = "~/chude/" + "11" + "_" + GetTieuDe("Song sinh") + ".aspx";
    }
}